<template>
	<view>
	
		
			请输入新密码：<u--input v-model="form.password"></u--input>
				
		
			<u-button @click="submit"	>提交</u-button>
			
			
	
	</view>
</template>

<script>
	import token from '@/common/token/token.js'
	
	export default {
		data() {
			return {
				form:{
					id:token.id,
					password:''
				},
				list1:{
						type: 'error',
						icon: false,
						title: '失败主题',
						message: "账号密码错误！",
						iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
				}
			}
		},
		methods:{
			submit(){
			console.log(this.form.id);
				this.$api({
					method: 'post',
					url: `/system/login/updatePassword`,
					 data: this.form
				}).then(res => {
					// uni.setStorageSync('token', res.data);
				
					if (res.data != null) {
						uni.redirectTo({
							url:'/pages/user/user'
						})
						
					} else {
							// console.log(res.data);
						// this.showToast(this.list1),
						this.showToast(this.list1),
						console.log("失败");
					}
					
				}).catch(err => {
					console.log(err)
				});
			}
		},
		showToast(params) {
			console.log(params);
			this.$refs.uToast.show({
				...params,
				complete() {
					params.url && uni.navigateTo({
						url: params.url
					})
				}
			})
		},
		onload(){
			
		}
	}
</script>

<style lang="scss">

</style>
